package com.ucode.wap.hrm.controller;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.ucode.hrm.service.HrmPaySlipService;
import com.ucode.model.hrm.HrmPaySlip;
import com.ucode.tool.annotation.NeedLogin;
import com.ucode.tool.base.Paginator;
import com.ucode.tool.base.ResponseResult;
import com.ucode.wap.hrm.service.ApiHrmEmployeeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Tag(name = "移动端 - 人力资源系统 - 员工工资条")
@RestController
@RequestMapping("/hrm/pay-slip")
@Validated
public class ApiHrmPaySlipController {
    private static final Log log = LogFactory.get();

    @Resource
    private HrmPaySlipService hrmPaySlipService;
    @Resource
    private ApiHrmEmployeeService apiHrmEmployeeService;

    @NeedLogin(validate = true)
    @GetMapping("/page-list")
    @Operation(summary = "获得分页列表")
    public ResponseResult<Paginator<HrmPaySlip>> pageList(
            @Schema(description = "页码",example="1") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @Schema(description = "每页记录数",example="5") @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize){

        Map<String,Object> condition = new HashMap<>();
        condition.put("employeeId",apiHrmEmployeeService.verifyCurrentUserBindAndGetEmployeeId());
        condition.put("visible",true);
        condition.put("deltag",false);
        Paginator<HrmPaySlip> paginator = hrmPaySlipService.queryPageForList(condition,pageSize,pageNum);
        return ResponseResult.success(paginator);
    }
}
